<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>

<%@ page import="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter" %>
<%@ page import="org.springframework.security.core.AuthenticationException" %>

<script type="text/javascript">
	$(function() {
		$( "#tabs" ).tabs();
	});
</script>
<div class="demo">
	<div id="tabs">
		<ul>
			<li><a href="#tabs-1">Login</a></li>
		</ul>
		<div id="tabs-1">
			<p>
				<c:if test="${not empty param.login_error}">
					<div class="error">
						Your login attempt was not successful, try again.<br /><br />
						Reason: <%= ((AuthenticationException) session.getAttribute(UsernamePasswordAuthenticationFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY)).getMessage() %>
					</div>
				</c:if>
				<form id="login" name="f" action="j_spring_security_check" method="post">
					<p>
						<label for="j_username">User:</label>
						<br />
						<input type="text" name="j_username" id="j_username" <c:if test="${not empty param.login_error}">value="<%= session.getAttribute(UsernamePasswordAuthenticationFilter.SPRING_SECURITY_LAST_USERNAME_KEY) %>"</c:if> autofocus required />
					</p>
					<p>
						<label for="j_password">Password:</label>
						<br />
						<input type="password" name="j_password" id="j_password" required/>
					</p>
					<p>
						<input type="checkbox" name="_spring_security_remember_me" id="remember_me" />
						<label for="remember_me">Don't ask for my password for two weeks:</label>
					</p>
					<p>
						<button id="submit" type="submit" class="fancybox">Login</button>&nbsp;
						<security:authorize ifAllGranted="ROLE_ADMIN">
							<a href="<c:url value="/users/register" />">Register</a>
						</security:authorize>
					</p>
				</form>
			</p>
		</div>
	</div>
</div>
